package com.bitcs.accesscontrol.util;

import com.alibaba.fastjson.JSON;

/**
 * @author GeChen
 */
public class ResponseUtil<T> {
    private Integer error;
    private String message;
    private T data;

    public Integer getError() {
        return error;
    }

    public void setError(Integer error) {
        this.error = error;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static String getResponseString(Integer errorCode, String message, Object data) {
        ResponseUtil response = new ResponseUtil();
        response.setError(errorCode);
        response.setMessage(message);
        response.setData(data);
        return JSON.toJSONString(response);
    }

    @Override
    public String toString() {
        return "ResponseUtil{" +
                "error=" + error +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
